// 封装按钮权限
import pinia from '../store'
import useUserStore from '@/store/modules/user'

const userStore = useUserStore(pinia)

const permissionCheck = (permissionKey) => {
    if (!permissionKey) {
        return false
    }

    // 取出用户权限
    const userPermissions = userStore.permissions || JSON.parse(localStorage.getItem("USER_PERMISSION"))

    console.log(userPermissions)

    if (userPermissions == null) {
        return false
    }

    let permissionStatus = null

    userPermissions.forEach(permission => {
        permissionKey.forEach(key => {
            if (permission == key) {
                permissionStatus = true
            }
        })
    })

    return permissionStatus
}

export default permissionCheck